unit Class_Card_4UNI;


interface
uses
  Classes,SysUtils,DB,Uni,UniEngine;

type
  TCARD4UNI=class(TUniEngine)
  private
    FUNITLINK : string;
    FCARDIDEX : Integer;
    FCARDBDID : Integer;
    FCARDKJND : Integer;
    FCARDKJQJ : Integer;
    FZJJLIDEX : Integer;
    FZJJLYZJE : Extended;
    FZJJLZCYZ : Extended;
    FZJJLZCJZ : Extended;
    FZJJLLJZJ : Extended;
    FZJJLYWBZ : Integer;
    FDATASTAT : Integer;
    FZJJLZJNX : Integer;
    FKJNDKJQJ : Integer;
    FZJJLDATE : TDateTime;
    FCARDBTZJ : Extended;
    FCARDNAME : string;
    FCARDCODE : string;
    FDEPTLINK : string;
    FZCLBLINK : string;
    FCARDZJLY : string;
    FCARDGRRQ : Integer;
    FCARDZCYZ : Extended;
    FCARDYJCZ : Extended;
    FCARDZJNX : Integer;
    FCARDZJZT : string;
    FZCLBJTBL : Extended;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    //#function  GetNextIndx:Integer;overload;
    //#function  GetNextIndx(aUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(aUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property UNITLINK : string read FUNITLINK  write FUNITLINK;
    property CARDIDEX : Integer read FCARDIDEX  write FCARDIDEX;
    property CARDBDID : Integer read FCARDBDID  write FCARDBDID;
    property CARDKJND : Integer read FCARDKJND  write FCARDKJND;
    property CARDKJQJ : Integer read FCARDKJQJ  write FCARDKJQJ;
    property ZJJLIDEX : Integer read FZJJLIDEX  write FZJJLIDEX;
    property ZJJLYZJE : Extended read FZJJLYZJE  write FZJJLYZJE;
    property ZJJLZCYZ : Extended read FZJJLZCYZ  write FZJJLZCYZ;
    property ZJJLZCJZ : Extended read FZJJLZCJZ  write FZJJLZCJZ;
    property ZJJLLJZJ : Extended read FZJJLLJZJ  write FZJJLLJZJ;
    property ZJJLYWBZ : Integer read FZJJLYWBZ  write FZJJLYWBZ;
    property DATASTAT : Integer read FDATASTAT  write FDATASTAT;
    property ZJJLZJNX : Integer read FZJJLZJNX  write FZJJLZJNX;
    property KJNDKJQJ : Integer read FKJNDKJQJ  write FKJNDKJQJ;
    property ZJJLDATE : TDateTime read FZJJLDATE  write FZJJLDATE;
    property CARDBTZJ : Extended read FCARDBTZJ  write FCARDBTZJ;
    property CARDNAME : string read FCARDNAME  write FCARDNAME;
    property CARDCODE : string read FCARDCODE  write FCARDCODE;
    property DEPTLINK : string read FDEPTLINK  write FDEPTLINK;
    property ZCLBLINK : string read FZCLBLINK  write FZCLBLINK;
    property CARDZJLY : string read FCARDZJLY  write FCARDZJLY;
    property CARDGRRQ : Integer read FCARDGRRQ  write FCARDGRRQ;
    property CARDZCYZ : Extended read FCARDZCYZ  write FCARDZCYZ;
    property CARDYJCZ : Extended read FCARDYJCZ  write FCARDYJCZ;
    property CARDZJNX : Integer read FCARDZJNX  write FCARDZJNX;
    property CARDZJZT : string read FCARDZJZT  write FCARDZJZT;
    property ZCLBJTBL : Extended read FZCLBJTBL  write FZCLBJTBL;    
  public
    class function  ReadDS(aUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(aUniQuery:TUniQuery;var Result:TUniEngine);override;

    class function  CopyIt(aVIEWCARDADOUNI:TCARD4UNI):TCARD4UNI;overload;        
    class procedure CopyIt(aVIEWCARDADOUNI:TCARD4UNI;var Result:TCARD4UNI);overload;       

    class function  CopyIt(aUniEngine:TUniEngine):TUniEngine;overload;override;
    class procedure CopyIt(aUniEngine:TUniEngine;var Result:TUniEngine)overload;override;
  end;

implementation


procedure TCARD4UNI.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('CARD_IDEX').Value := CARDIDEX;
        ParamByName('CARD_BDID').Value := CARDBDID;
        ParamByName('CARD_KJND').Value := CARDKJND;
        ParamByName('CARD_KJQJ').Value := CARDKJQJ;
        ParamByName('ZJJL_IDEX').Value := ZJJLIDEX;
        ParamByName('ZJJL_YZJE').Value := ZJJLYZJE;
        ParamByName('ZJJL_ZCYZ').Value := ZJJLZCYZ;
        ParamByName('ZJJL_ZCJZ').Value := ZJJLZCJZ;
        ParamByName('ZJJL_LJZJ').Value := ZJJLLJZJ;
        ParamByName('ZJJL_YWBZ').Value := ZJJLYWBZ;
        ParamByName('DATA_STAT').Value := DATASTAT;
        ParamByName('ZJJL_ZJNX').Value := ZJJLZJNX;
        ParamByName('KJND_KJQJ').Value := KJNDKJQJ;
        ParamByName('ZJJL_DATE').Value := ZJJLDATE;
        ParamByName('CARD_BTZJ').Value := CARDBTZJ;
        ParamByName('CARD_NAME').Value := CARDNAME;
        ParamByName('CARD_CODE').Value := CARDCODE;
        ParamByName('DEPT_LINK').Value := DEPTLINK;
        ParamByName('ZCLB_LINK').Value := ZCLBLINK;
        ParamByName('CARD_ZJLY').Value := CARDZJLY;
        ParamByName('CARD_GRRQ').Value := CARDGRRQ;
        ParamByName('CARD_ZCYZ').Value := CARDZCYZ;
        ParamByName('CARD_YJCZ').Value := CARDYJCZ;
        ParamByName('CARD_ZJNX').Value := CARDZJNX;
        ParamByName('CARD_ZJZT').Value := CARDZJZT;
        ParamByName('ZCLB_JTBL').Value := ZCLBJTBL; 
      end;
      otEdit:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('CARD_IDEX').Value := CARDIDEX;
        ParamByName('CARD_BDID').Value := CARDBDID;
        ParamByName('CARD_KJND').Value := CARDKJND;
        ParamByName('CARD_KJQJ').Value := CARDKJQJ;
        ParamByName('ZJJL_IDEX').Value := ZJJLIDEX;
        ParamByName('ZJJL_YZJE').Value := ZJJLYZJE;
        ParamByName('ZJJL_ZCYZ').Value := ZJJLZCYZ;
        ParamByName('ZJJL_ZCJZ').Value := ZJJLZCJZ;
        ParamByName('ZJJL_LJZJ').Value := ZJJLLJZJ;
        ParamByName('ZJJL_YWBZ').Value := ZJJLYWBZ;
        ParamByName('DATA_STAT').Value := DATASTAT;
        ParamByName('ZJJL_ZJNX').Value := ZJJLZJNX;
        ParamByName('KJND_KJQJ').Value := KJNDKJQJ;
        ParamByName('ZJJL_DATE').Value := ZJJLDATE;
        ParamByName('CARD_BTZJ').Value := CARDBTZJ;
        ParamByName('CARD_NAME').Value := CARDNAME;
        ParamByName('CARD_CODE').Value := CARDCODE;
        ParamByName('DEPT_LINK').Value := DEPTLINK;
        ParamByName('ZCLB_LINK').Value := ZCLBLINK;
        ParamByName('CARD_ZJLY').Value := CARDZJLY;
        ParamByName('CARD_GRRQ').Value := CARDGRRQ;
        ParamByName('CARD_ZCYZ').Value := CARDZCYZ;
        ParamByName('CARD_YJCZ').Value := CARDYJCZ;
        ParamByName('CARD_ZJNX').Value := CARDZJNX;
        ParamByName('CARD_ZJZT').Value := CARDZJZT;
        ParamByName('ZCLB_JTBL').Value := ZCLBJTBL; 
      end;  
      otDelt:
      begin
        ParamByName('UNIT_LINK').Value := UNITLINK;
        ParamByName('CARD_IDEX').Value := CARDIDEX;
        ParamByName('CARD_BDID').Value := CARDBDID;
 
      end;  
    end;
  end;
end;

function TCARD4UNI.CheckExist(aUniConnection: TUniConnection): Boolean;
begin
  Result := CheckExist('VIEW_CARD_ADO_UNI',['UNIT_LINK',UNITLINK,'CARD_IDEX',CARDIDEX,'CARD_BDID',CARDBDID],AUniConnection);
end;

function TCARD4UNI.GetStrDelete: string;
begin
  Result:='DELETE FROM VIEW_CARD_ADO_UNI WHERE   UNIT_LINK=:UNIT_LINK AND CARD_IDEX=:CARD_IDEX AND CARD_BDID=:CARD_BDID';
end;

function TCARD4UNI.GetStrInsert: string;
begin
  Result:='INSERT INTO VIEW_CARD_ADO_UNI'
         +'    ( UNIT_LINK, CARD_IDEX, CARD_BDID, CARD_KJND, CARD_KJQJ'
         +'    , ZJJL_IDEX, ZJJL_YZJE, ZJJL_ZCYZ, ZJJL_ZCJZ, ZJJL_LJZJ'
         +'    , ZJJL_YWBZ, DATA_STAT, ZJJL_ZJNX, KJND_KJQJ, ZJJL_DATE'
         +'    , CARD_BTZJ, CARD_NAME, CARD_CODE, DEPT_LINK, ZCLB_LINK'
         +'    , CARD_ZJLY, CARD_GRRQ, CARD_ZCYZ, CARD_YJCZ, CARD_ZJNX'
         +'    , CARD_ZJZT, ZCLB_JTBL)'
         +'    VALUES'
         +'    (:UNIT_LINK,:CARD_IDEX,:CARD_BDID,:CARD_KJND,:CARD_KJQJ'
         +'    ,:ZJJL_IDEX,:ZJJL_YZJE,:ZJJL_ZCYZ,:ZJJL_ZCJZ,:ZJJL_LJZJ'
         +'    ,:ZJJL_YWBZ,:DATA_STAT,:ZJJL_ZJNX,:KJND_KJQJ,:ZJJL_DATE'
         +'    ,:CARD_BTZJ,:CARD_NAME,:CARD_CODE,:DEPT_LINK,:ZCLB_LINK'
         +'    ,:CARD_ZJLY,:CARD_GRRQ,:CARD_ZCYZ,:CARD_YJCZ,:CARD_ZJNX'
         +'    ,:CARD_ZJZT,:ZCLB_JTBL)';
end;

function TCARD4UNI.GetStrsIndex: string;
begin
  Result:=Format('%S-%D-%D',[UNITLINK,CARDIDEX,CARDBDID]);
end;

function TCARD4UNI.GetStrUpdate: string;
begin
  Result:='UPDATE  VIEW_CARD_ADO_UNI SET'
         +'    CARD_KJND=:CARD_KJND,'
         +'    CARD_KJQJ=:CARD_KJQJ,'
         +'    ZJJL_IDEX=:ZJJL_IDEX,'
         +'    ZJJL_YZJE=:ZJJL_YZJE,'
         +'    ZJJL_ZCYZ=:ZJJL_ZCYZ,'
         +'    ZJJL_ZCJZ=:ZJJL_ZCJZ,'
         +'    ZJJL_LJZJ=:ZJJL_LJZJ,'
         +'    ZJJL_YWBZ=:ZJJL_YWBZ,'
         +'    DATA_STAT=:DATA_STAT,'
         +'    ZJJL_ZJNX=:ZJJL_ZJNX,'
         +'    KJND_KJQJ=:KJND_KJQJ,'
         +'    ZJJL_DATE=:ZJJL_DATE,'
         +'    CARD_BTZJ=:CARD_BTZJ,'
         +'    CARD_NAME=:CARD_NAME,'
         +'    CARD_CODE=:CARD_CODE,'
         +'    DEPT_LINK=:DEPT_LINK,'
         +'    ZCLB_LINK=:ZCLB_LINK,'
         +'    CARD_ZJLY=:CARD_ZJLY,'
         +'    CARD_GRRQ=:CARD_GRRQ,'
         +'    CARD_ZCYZ=:CARD_ZCYZ,'
         +'    CARD_YJCZ=:CARD_YJCZ,'
         +'    CARD_ZJNX=:CARD_ZJNX,'
         +'    CARD_ZJZT=:CARD_ZJZT,'
         +'    ZCLB_JTBL=:ZCLB_JTBL'
         +'    WHERE UNIT_LINK=:UNIT_LINK'
         +'    AND   CARD_IDEX=:CARD_IDEX'
         +'    AND   CARD_BDID=:CARD_BDID';
end;

constructor TCARD4UNI.Create;
begin

end;

destructor TCARD4UNI.Destroy;
begin

  inherited;
end;

class function TCARD4UNI.ReadDS(aUniQuery: TUniQuery): TUniEngine;
begin
  Result := TCARD4UNI.Create;
  TCARD4UNI.ReadDS(AUniQuery,Result);
end;

class procedure TCARD4UNI.ReadDS(aUniQuery: TUniQuery; var Result: TUniEngine);
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  if Result = nil then Exit;

  with TCARD4UNI(Result) do
  begin
    for I:=0 to aUniQuery.Fields.Count-1 do
    begin
      Field := aUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName := UpperCase(Field.FieldName);
      if FieldName = 'UNIT_LINK' then
      begin
        UNITLINK  := Field.AsString;
      end else
      if FieldName = 'CARD_IDEX' then
      begin
        CARDIDEX  := Field.AsInteger;
      end else
      if FieldName = 'CARD_BDID' then
      begin
        CARDBDID  := Field.AsInteger;
      end else
      if FieldName = 'CARD_KJND' then
      begin
        CARDKJND  := Field.AsInteger;
      end else
      if FieldName = 'CARD_KJQJ' then
      begin
        CARDKJQJ  := Field.AsInteger;
      end else
      if FieldName = 'ZJJL_IDEX' then
      begin
        ZJJLIDEX  := Field.AsInteger;
      end else
      if FieldName = 'ZJJL_YZJE' then
      begin
        ZJJLYZJE  := Field.AsFloat;
      end else
      if FieldName = 'ZJJL_ZCYZ' then
      begin
        ZJJLZCYZ  := Field.AsFloat;
      end else
      if FieldName = 'ZJJL_ZCJZ' then
      begin
        ZJJLZCJZ  := Field.AsFloat;
      end else
      if FieldName = 'ZJJL_LJZJ' then
      begin
        ZJJLLJZJ  := Field.AsFloat;
      end else
      if FieldName = 'ZJJL_YWBZ' then
      begin
        ZJJLYWBZ  := Field.AsInteger;
      end else
      if FieldName = 'DATA_STAT' then
      begin
        DATASTAT  := Field.AsInteger;
      end else
      if FieldName = 'ZJJL_ZJNX' then
      begin
        ZJJLZJNX  := Field.AsInteger;
      end else
      if FieldName = 'KJND_KJQJ' then
      begin
        KJNDKJQJ  := Field.AsInteger;
      end else
      if FieldName = 'ZJJL_DATE' then
      begin
        ZJJLDATE  := Field.AsDateTime;
      end else
      if FieldName = 'CARD_BTZJ' then
      begin
        CARDBTZJ  := Field.AsFloat;
      end else
      if FieldName = 'CARD_NAME' then
      begin
        CARDNAME  := Field.AsString;
      end else
      if FieldName = 'CARD_CODE' then
      begin
        CARDCODE  := Field.AsString;
      end else
      if FieldName = 'DEPT_LINK' then
      begin
        DEPTLINK  := Field.AsString;
      end else
      if FieldName = 'ZCLB_LINK' then
      begin
        ZCLBLINK  := Field.AsString;
      end else
      if FieldName = 'CARD_ZJLY' then
      begin
        CARDZJLY  := Field.AsString;
      end else
      if FieldName = 'CARD_GRRQ' then
      begin
        CARDGRRQ  := Field.AsInteger;
      end else
      if FieldName = 'CARD_ZCYZ' then
      begin
        CARDZCYZ  := Field.AsFloat;
      end else
      if FieldName = 'CARD_YJCZ' then
      begin
        CARDYJCZ  := Field.AsFloat;
      end else
      if FieldName = 'CARD_ZJNX' then
      begin
        CARDZJNX  := Field.AsInteger;
      end else
      if FieldName = 'CARD_ZJZT' then
      begin
        CARDZJZT  := Field.AsString;
      end else
      if FieldName = 'ZCLB_JTBL' then
      begin
        ZCLBJTBL  := Field.AsFloat;
      end;
    end
  end;  
end;

class function  TCARD4UNI.CopyIt(aVIEWCARDADOUNI: TCARD4UNI): TCARD4UNI;
begin
  Result := TCARD4UNI.Create;
  TCARD4UNI.CopyIt(aVIEWCARDADOUNI,Result)
end;

class procedure TCARD4UNI.CopyIt(aVIEWCARDADOUNI:TCARD4UNI;var Result:TCARD4UNI);
begin
  if Result = nil then Exit;
  Result.UNITLINK := aVIEWCARDADOUNI.UNITLINK;
  Result.CARDIDEX := aVIEWCARDADOUNI.CARDIDEX;
  Result.CARDBDID := aVIEWCARDADOUNI.CARDBDID;
  Result.CARDKJND := aVIEWCARDADOUNI.CARDKJND;
  Result.CARDKJQJ := aVIEWCARDADOUNI.CARDKJQJ;
  Result.ZJJLIDEX := aVIEWCARDADOUNI.ZJJLIDEX;
  Result.ZJJLYZJE := aVIEWCARDADOUNI.ZJJLYZJE;
  Result.ZJJLZCYZ := aVIEWCARDADOUNI.ZJJLZCYZ;
  Result.ZJJLZCJZ := aVIEWCARDADOUNI.ZJJLZCJZ;
  Result.ZJJLLJZJ := aVIEWCARDADOUNI.ZJJLLJZJ;
  Result.ZJJLYWBZ := aVIEWCARDADOUNI.ZJJLYWBZ;
  Result.DATASTAT := aVIEWCARDADOUNI.DATASTAT;
  Result.ZJJLZJNX := aVIEWCARDADOUNI.ZJJLZJNX;
  Result.KJNDKJQJ := aVIEWCARDADOUNI.KJNDKJQJ;
  Result.ZJJLDATE := aVIEWCARDADOUNI.ZJJLDATE;
  Result.CARDBTZJ := aVIEWCARDADOUNI.CARDBTZJ;
  Result.CARDNAME := aVIEWCARDADOUNI.CARDNAME;
  Result.CARDCODE := aVIEWCARDADOUNI.CARDCODE;
  Result.DEPTLINK := aVIEWCARDADOUNI.DEPTLINK;
  Result.ZCLBLINK := aVIEWCARDADOUNI.ZCLBLINK;
  Result.CARDZJLY := aVIEWCARDADOUNI.CARDZJLY;
  Result.CARDGRRQ := aVIEWCARDADOUNI.CARDGRRQ;
  Result.CARDZCYZ := aVIEWCARDADOUNI.CARDZCYZ;
  Result.CARDYJCZ := aVIEWCARDADOUNI.CARDYJCZ;
  Result.CARDZJNX := aVIEWCARDADOUNI.CARDZJNX;
  Result.CARDZJZT := aVIEWCARDADOUNI.CARDZJZT;
  Result.ZCLBJTBL := aVIEWCARDADOUNI.ZCLBJTBL;
end;

class function TCARD4UNI.CopyIt(aUniEngine: TUniEngine): TUniEngine;
begin
  Result := TCARD4UNI.Create;
  TUniEngine.CopyIt(aUniEngine,Result);
end;

class procedure TCARD4UNI.CopyIt(aUniEngine: TUniEngine; var Result: TUniEngine);
begin
  if Result = nil then Exit;
  TCARD4UNI.CopyIt(TCARD4UNI(aUniEngine),TCARD4UNI(Result));
end;

end.
